import httprequest from '@/utils/request'
import config from '@/utils/config'

// 文件上传
export function fileUpload(tempFile , data){
	return new Promise((resolve, reject) => {
		// #ifndef MP
		uni.uploadFile({
			url: config.apiUrl+'/api/upload/file',
			filePath: tempFile,
			name: 'file',
			formData: data,
			success: (res) => {
				console.log(typeof res.data)
				resolve(res.data)
			}
		});
		// #endif
		
		// #ifdef MP
		wx.uploadFile({
		    url: config.apiUrl+'/api/upload/file',
		    filePath: tempFile,
		    name: 'file',
		 
		    success:function(res){
				resolve(JSON.parse(res.data))
		    }
		})
		// #endif
	})	
}
// 小程序code登录
export function mpLogin(data){
	return httprequest({
	    url: config.apiUrl+'/api/login/mp',
	    method: 'post',
		showLoad: false,
		data,
	})
}
// 测试模拟登录
export function mpLoginFake(){
	return httprequest({
	    url: config.apiUrl+'/api/login/mpFake',
	    method: 'post',
		showLoad: false,
	})
}

// 小程序退出登录
export function mpLogout(data){
	return httprequest({
	    url: config.apiUrl+'/api/user/logout',
	    method: 'post',
		showLoad: false,
		data,
	})
}
// 每日登陆日志
export function loginRecords(data){
	return httprequest({
	    url: config.apiUrl+'/api/user/loginRecords',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 我的地址列表
export function getUserAddress(){
	return httprequest({
	    url: config.apiUrl+'/api/user/address',
	    method: 'get',
		showLoad: false,
	})
}
// 保存用户信息
export function saveUserInfo(fromType,data){
	return httprequest({
	    url: config.apiUrl+`/api/user/saveInfo?fromtype=${fromType}`,
	    method: 'post',
		showLoad: false,
		data,
	})
}
// 我的地址列表
export function getAddressInfo(addressId){
	return httprequest({
	    url: config.apiUrl+`/api/user_address/details?id=${addressId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 保存地址
export function saveAddressInfo(data){
	return httprequest({
	    url: config.apiUrl+'/api/user_address/save',
	    method: 'post',
		showLoad: false,
		data,
	})
}
// 删除地址
export function deleteUserAddress(addressId){
	return httprequest({
	    url: config.apiUrl+`/api/user_address/delAddress?id=${addressId}`,
	    method: 'delete',
		showLoad: false,
	})
}
// 热门搜索词
export function getHotSearch(){
	return httprequest({
	    url: config.apiUrl+'/api/hot_search/words',
	    method: 'get',
		showLoad: false,
	})
}
// 根据js_code获取微信用户手机号
export function wechatPhoneNumber(data){
	return httprequest({
	    url: config.apiUrl+'/api/user/wechatPhonenumber',
	    method: 'post',
		showLoad: false,
		data,
	})
}
// 获取用户实名信息
export function idcardInfo(){
	return httprequest({
	    url: config.apiUrl+'/api/idcard/info',
	    method: 'get',
		showLoad: false
	})
}
// 根据用户实名信息
export function idcardInfoSave(data){
	return httprequest({
	    url: config.apiUrl+'/api/idcard/saveInfo',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 获取销售经理的客户列表
export function customerList(filter){
	return httprequest({
	    url: config.apiUrl+`/api/customer/customers${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
export function customerInfo(cusUid){
	return httprequest({
	    url: config.apiUrl+`/api/customer/info?uid=${cusUid}`,
	    method: 'get',
		showLoad: false,
	})
}

// 获取销售经理的客户统计
export function customerStatistic(){
	return httprequest({
	    url: config.apiUrl+'/api/customer/statistic',
	    method: 'get',
		showLoad: false,
	})
}
// 获取销售经理的销售统计
export function salesStatistic(){
	return httprequest({
	    url: config.apiUrl+'/api/customer/salesStatistic',
	    method: 'get',
		showLoad: false,
	})
}
// 保存客户信息
export function customerInfoSave(data){
	return httprequest({
	    url: config.apiUrl+'/api/customer/saveInfo',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 保存添加客户信息
export function customerAddSave(data){
	return httprequest({
	    url: config.apiUrl+'/api/customer/saveNew',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 保存添加/修改客户身份证信息
export function customerIdnumberSave(data){
	return httprequest({
	    url: config.apiUrl+'/api/customer/saveIdcard',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 保存客户提醒设置
export function customerNoticeSave(data){
	return httprequest({
	    url: config.apiUrl+'/api/customer/saveNotice',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 保存客户提醒设置
export function getCustomerNotices(filter){
	return httprequest({
	    url: config.apiUrl+`/api/customer/notices${filter}`,
	    method: 'get',
		showLoad: false,
	})
}

// 保存客户跟进信息
export function cusProcessonSave(data){
	return httprequest({
	    url: config.apiUrl+'/api/customer/saveProcesson',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 客户跟进信息列表
export function getCustomerProcessons(filter){
	return httprequest({
	    url: config.apiUrl+`/api/customer/processons${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 金币商城商品列表
export function goldsMallGoods(goodsType,page){
	return httprequest({
	    url: config.apiUrl+`/api/golds_mall/goods?goods_type=${goodsType}&page=${page}`,
	    method: 'get',
		showLoad: false,
	})
}
// 金币商城订单
export function getMallOrders(outerStatus,page){
	return httprequest({
	    url: config.apiUrl+`/api/order/mall?outer_status=${outerStatus}&page=${page}`,
	    method: 'get',
		showLoad: false,
	})
}
export function mallOrderConfirmReciver(orderId){
	return httprequest({
	    url: config.apiUrl+`/api/order/mallRecive`,
	    method: 'post',
		showLoad: false,
		data: {
			order_id: orderId
		}
	})
}
// 线路订单
export function getRoutesOrders(filter){
	return httprequest({
	    url: config.apiUrl+`/api/order/routers${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取用户订单统计
export function getUserOrderStatistic(filter){
	return httprequest({
	    url: config.apiUrl+`/api/user/orderStatic${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 金币商城商品详情
export function goldsMallGoodsDetails(goodsId){
	return httprequest({
	    url: config.apiUrl+`/api/golds_mall/details?goods_id=${goodsId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 金币记录
export function getUserGoldsBills(stype,page){
	return httprequest({
	    url: config.apiUrl+`/api/bills/golds?stype=${stype}&page=${page}`,
	    method: 'get',
		showLoad: false,
	})
}
// 金币商城商品类别
export function goldsMallGoodsTypes(){
	return httprequest({
	    url: config.apiUrl+'/api/golds_mall/types',
	    method: 'get',
		showLoad: false,
	})
}
// 获取用户已领取的所有代金券
export function getUserCoupons(filter){
	return httprequest({
	    url: config.apiUrl+`/api/user/coupons${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取用户代金券领取记录详情
export function getCouponRecordDetails(recordId){
	return httprequest({
	    url: config.apiUrl+`/api/user/couponRecordDetails?id=${recordId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 核销代金券
export function verifyCouponRecord(data){
	return httprequest({
	    url: config.apiUrl+`/api/user/couponRecordVerify`,
	    method: 'post',
		showLoad: false,
		data
	})
}
// 获取用户红点提示信息数量
export function getRedDotTipNums(){
	return httprequest({
	    url: config.apiUrl+'/api/user/redDotTipNums',
	    method: 'get',
		showLoad: false,
	})
}
// 订单统一创建
export function orderUnionCreate(data){
	return httprequest({
	    url: config.apiUrl+'/api/order/create',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 订单统一支付
export function orderUnionPayment(orderId){
	return httprequest({
	    url: config.apiUrl+'/api/order/payment',
	    method: 'post',
		showLoad: false,
		data: {
			order_id: orderId
		}
	})
}
// 获取banner列表
export function indexBanners(){
	return httprequest({
	    url: config.apiUrl+'/api/banner/banners',
	    method: 'get',
		showLoad: false,
	})
}
// 获取路线列表
export function routerList(filter){
	return httprequest({
	    url: config.apiUrl+`/api/routes/routes${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取推荐路线列表
export function recommandRouters(filter){
	return httprequest({
	    url: config.apiUrl+`/api/recomand/routes${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取路线详情
export function getRoutesDetails(routeId){
	return httprequest({
	    url: config.apiUrl+`/api/routes/details?route_id=${routeId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取路线SKU列表
export function routesSkuList(routeId){
	return httprequest({
	    url: config.apiUrl+`/api/routes/skuList?route_id=${routeId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取路线SKU列表
export function routesSkuPrice(routeId,skuId,month){
	return httprequest({
	    url: config.apiUrl+`/api/routes/skuPrice?route_id=${routeId}&sku_id=${skuId}&month=${month}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取首页图标推荐位列表
export function recomandIcons(){
	return httprequest({
	    url: config.apiUrl+'/api/recomand/icons',
	    method: 'get',
		showLoad: false,
	})
}
// 获取推荐位详情
export function recomandDetails(recomandId){
	return httprequest({
	    url: config.apiUrl+`/api/recomand/view?id=${recomandId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取首页文字推荐位列表
export function recomandTexts(){
	return httprequest({
	    url: config.apiUrl+'/api/recomand/texts',
	    method: 'get',
		showLoad: false,
	})
}
// 获取用户签到任务以及完成情况
export function userSignTasks(){
	return httprequest({
	    url: config.apiUrl+'/api/sign_task/tasks',
	    method: 'get',
		showLoad: false,
	})
}
// 获取用户签到任务以及完成情况
export function signWeekRecords(){
	return httprequest({
	    url: config.apiUrl+'/api/sign/week_records',
	    method: 'get',
		showLoad: false,
	})
}
// 获取用户周连续签到天数
export function signWeekPersist(){
	return httprequest({
	    url: config.apiUrl+'/api/sign/week_persist',
	    method: 'get',
		showLoad: false,
	})
}
// 用户签到记录
export function userSign(){
	return httprequest({
	    url: config.apiUrl+'/api/sign/record',
	    method: 'get',
		showLoad: false
	})
}
// 直播回放列表
export function livingReplays(){
	return httprequest({
	    url: config.apiUrl+'/api/living/replays',
	    method: 'get',
		showLoad: false,
	})
}
// 直播回放增加播放次数
export function livingReplayPlusPlays(replayId){
	return httprequest({
	    url: config.apiUrl+'/api/living/replaysPlusPlays',
	    method: 'post',
		showLoad: false,
		data: {
			replay_id: replayId
		}
	})
}

// 获取客服信息
export function kfService(){
	return httprequest({
	    url: config.apiUrl+'/api/misc/kfService',
	    method: 'get',
		showLoad: false,
	})
}

// 获取会员等级列表
export function userLevel(){
	return httprequest({
	    url: config.apiUrl+'/api/user_level/levels',
	    method: 'get',
		showLoad: false,
	})
}
// 会员开通/续费/升级前置检查
export function userPrimePrecheck(data){
	return httprequest({
	    url: config.apiUrl+'/api/user/primePrecheck',
	    method: 'post',
		showLoad: false,
		data
	})
}
// 重新拉取用户会员等级信息（一般用于会员开通、升级、续费后刷新页面及更新本地缓存用）
export function resyncPrimeInfo(){
	return httprequest({
	    url: config.apiUrl+'/api/user/resyncPrimeInfo',
	    method: 'post',
		showLoad: false
	})
}
// 重新拉取用户信息
export function resyncUserInfo(){
	return httprequest({
	    url: config.apiUrl+'/api/user/resyncUserInfo',
	    method: 'post',
		showLoad: false
	})
}
// 获取我的团队成员
export function teammembers(){
	return httprequest({
	    url: config.apiUrl+'/api/user/teammembers',
	    method: 'get',
		showLoad: false,
	})
}
// 用户消息列表
export function getUserMessages(filter){
	return httprequest({
	    url: config.apiUrl+`/api/user/messages${filter}`,
	    method: 'get',
		showLoad: false,
	})
}
// 用户消息标记已读
export function readUserMessages(id){
	return httprequest({
	    url: config.apiUrl+`/api/message/mark_read?id=${id}`,
	    method: 'post',
		showLoad: false,
	})
}
// 用户消息删除
export function clearUserMessages(id){
	return httprequest({
	    url: config.apiUrl+`/api/message/mark_clear?id=${id}`,
	    method: 'post',
		showLoad: false,
	})
}
// 获取消息详情
export function getMessageDetails(messageId){
	return httprequest({
	    url: config.apiUrl+`/api/message/view?id=${messageId}`,
	    method: 'get',
		showLoad: false,
	})
}
// 获取文章内容
export function getArticleDetails(apiName){
	return httprequest({
	    url: config.apiUrl+`/api/article/${apiName}`,
	    method: 'get',
		showLoad: false,
	})
}